#include <bits/stdc++.h>
// 2024/12/06
// tag: 
using namespace std;
int n, p, q, tree[101], t1[101];
string x, y;
unordered_map<string, int> name;
unordered_set<int> t;

int help(void){
    if (p == 0 && q == 0)
        return -1;
    if (q == 0)
        return 0;
    if (p == 0)
        return 1;
    if (q == 1 && p == 1)
        return 2;
    if (q == 1 && p > 1)
        return 3;
    if (q > 1 && p == 1)
        return 4;
    if (q > 1 && p > 1)
        return 5;
    return 6;
}
signed main()
{
    cin >> n >> x >> y;
    for (int i = 1, cnt = 1; i <= n; i++){
        string a, b;
        cin >> a >> b;
        if (!name[a]) name[a] = cnt++;
        if (!name[b]) name[b] = cnt++;
        tree[name[b]] = name[a];
    }
    for (int i = name[x], cnt = 0; i; i = tree[i], cnt++)
        t1[cnt] = i, t.insert(i);
    for (int i = name[y], cnt = 0; i; i = tree[i], cnt++)
        if (t.count(i)){
            p = cnt;
            for (q = 0; t1[q] != i; q++)
                ;
            q--;
            break;
        }
    switch (help())
    {
    case 0:
        cout << x << " is the ";
        while (q >= 3)
            cout << "great-", q--;
        if (q == 2)
            cout << "grand-";
        cout << "mother of " << y << endl;
        break;
    case 1:
        cout << y << " is the ";
        while (p >= 3)
            cout << "great-", p--;
        if (p == 2)
            cout << "grand-";
        cout << "mother of " << q << endl;
        break;
    case 2:
        cout << "SIBLINGS" << endl;
        break;
    case 3: 
        cout << x << " is the ";
        while (q >= 3)
            cout << "great-", q--;
        if (q == 2)
            cout << "grand-";
        cout << "aunt of " << y << endl;
        break;
    case 4:
        cout << y << " is the ";
        while (p >= 3)
            cout << "great-", p--;
        if (p == 2)
            cout << "grand-";
        cout << "aunt of " << x << endl;
        break;
    case 5:
        cout << "COUSINS" << endl;
        break;
    case -1:
        cout << "NOT RELATED" << endl;
        break;
    default:
        break;
    }
    return 0;
}